package com.neu.wangweili.servlet;

import com.neu.wangweili.service.W_StuService;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;
import java.io.IOException;
import java.util.List;
import java.util.Map;

@WebServlet(name = "LeftToCheckStuServlet", urlPatterns = {"/LeftToCheckStuServlet"})
public class LeftToCheckStuServlet extends HttpServlet {
    protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        request.setCharacterEncoding("UTF-8");
        String pageIndex=request.getParameter("pageIndex");
        W_StuService WStuService =new W_StuService();
//        每页显示的数据的条数
        int pageCount=3;
        String pageNum= WStuService.getPageNum(pageCount);

        List<Map<String,Object>>list=null;
        list= WStuService.findByPage(pageIndex,pageCount);
        if (list!=null){
            HttpSession session=request.getSession();
            session.setAttribute("pageNum",pageNum);
            session.setAttribute("pageIndex",pageIndex);
            session.setAttribute("item",list);
            System.out.println(pageNum);
        }
        request.getRequestDispatcher("WEB-INF/Mgr/checkstu.jsp").forward(request,response);
    }

    protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        doPost(request, response);
    }
}
